<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <meta http-equiv='X-UA-Compatible' content='ie=edge'>
    <title>Document</title>
</head>

<body>
    <div id='app'>
        <coma>
            <header slot="header">头部</header>
            <footer slot="footer">底部</footer>
        </coma>
        <hr>
        <!-- v-slot方式使用的版本  1.v-slot只能放在组件或template标签中  2.写法 v-slot:插槽名 -->
        <coma>
            <template v-slot:header>
                <header>头部</header>
            </template>
            <template v-slot:footer>
                <footer>底部</footer>
            </template>
        </coma>
        <hr>
        <!-- v-slot: 简写 #  -->
        <coma>
            <template #header>
                <header>头部</header>
            </template>
            <template #footer>
                <footer>底部</footer>
            </template>
        </coma>


    </div>
    <script src='https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js'></script>
    <script>
        Vue.component('coma', {
            template: `<div> <slot name="header"></slot>我是子组件 <slot name="footer"></slot></div>`
        });


        const vm = new Vue({
            el: '#app',
            data: {},
            methods: {},
        })
    </script>
</body>

</html>